<?php
/**
 * Created by PhpStorm.
 * User: wodrow
 * Date: 18-11-26
 * Time: 上午10:14
 */

namespace admin\modules\rbac\models;

use common\components\tools\ArrayHelper;
use common\components\tools\Tools;

class Menu extends \common\models\db\Menu
{
    public function rules()
    {
        $rules = parent::rules();
        $_r = [
            [['desc', 'yii2_app_id', 'uri', 'sort', 'created_at', 'created_by', 'updated_at', 'updated_by'], 'safe'],
        ];
        $rules = ArrayHelper::merge($rules, $_r);
        return $rules;
    }

    public function beforeSave($insert)
    {
        if ($this->isNewRecord){
            $this->created_at = $this->updated_at = Yii_BT_TIME;
            $this->created_by = $this->updated_by = \Yii::$app->user->identity->id;
        }else{
            $this->updated_at = Yii_BT_TIME;
            $this->updated_by = \Yii::$app->user->identity->id;
        }
        return parent::beforeSave($insert); // TODO: Change the autogenerated stub
    }
}